//
//  ShowViewBillboardCell.swift
//  iModern
//
//  Created by Ralf on 7/29/15.
//  Copyright (c) 2015 com.starlooking. All rights reserved.
//

import UIKit

class ShowViewBillboardCell: TableViewCell
{
    var label:    UILabel!
    var textView: UITextView!
    let message = "这里，原创匠人聚集；\n这里，展现匠人心工艺；\n开设匠铺，为万千手工爱好者打造良品生活。"

    override func awakeFromNib()
    {
        super.awakeFromNib()

        initLabel()
        initTextView()
        // Initialization code
        
    }

    override func setSelected(selected: Bool, animated: Bool)
    {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

    func initLabel()
    {
        if label == nil
        {
            let frame = CGRect(x: 10, y: 20, width: screen.width - 20, height: 30.0)
            label = UILabel(frame: frame)
            label.text = "爱魔登匠铺"
            label.textColor = UIColor.darkGrayColor()
            label.tintColor = UIColor.darkGrayColor()
            label.font = UIFont.boldSystemFontOfSize(24)
            addSubview(label)
        }
    }

    func initTextView()
    {
        if textView == nil
        {
            let frame = CGRect(x: 5.0, y: 50, width: screen.width - 10, height: 100)
            textView = UITextView(frame: frame)
            textView.textColor = UIColor.darkGrayColor()

            let paragraphStyle = NSMutableParagraphStyle()

            paragraphStyle.lineHeightMultiple = 16
            paragraphStyle.maximumLineHeight = 24
            paragraphStyle.minimumLineHeight = 24

            paragraphStyle.alignment = .Left

            let attributes = [NSFontAttributeName: UIFont.systemFontOfSize(14),
                              NSParagraphStyleAttributeName: paragraphStyle,
                              NSForegroundColorAttributeName: UIColor.darkGrayColor()]
            textView.attributedText = NSAttributedString(string: message, attributes: attributes)
            textView.userInteractionEnabled = false
            addSubview(textView)
        }
    }

    @IBAction func click(sender: UIButton)
    {
        if appDelegate.isLogged()
        {
            MobClick.event("Will become the boss")
            let BusinessVC = BusinessCertificationStep1Form()
            self.pushViewController(BusinessVC)

        }
        else
        {
            self.login()
        }
    }
}
